﻿using EYWeb.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EYWeb.WebLTE.App_Start.Handler
{
    public class LoginAttribute: AuthorizeAttribute
    {
        public bool Ignore = true;

        public LoginAttribute(bool ignore = true)
        {
            this.Ignore = ignore;
        }
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            if (Ignore == false) return;
            if (OperatorProvider.Provider.GetCurrent() == null)
            {
                WebHelper.WriteCookie("login_error", "Overdue");
                filterContext.HttpContext.Response.Write("<script>top.window.location.href='/Login/Index'</script>");
            }
        }
    }
}